package com.lan.support.response.ex;

public class Ex extends RuntimeException {

    private Integer code = -1000;
    private String name;

    private ExCode ex;

    public Ex(String name) {
        this.name = name;
    }

    public Ex(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Ex(ExCode ex) {
        this.ex = ex;
        this.code = ex.getCode();
        this.name = ex.getName();
    }

    public Ex(ExCode ex, String message) {
        this.ex = ex;
        this.code = ex.getCode();
        this.name = ex.getName() + message;

    }

    public static Ex build(ExCode code) {
        return new Ex(code);
    }

    public static Ex build(ExCode code, String message) {
        return new Ex(code, message);
    }

    public static Ex build(String name) {
        return new Ex(name);
    }

    @Override
    public String getMessage() {
        return name;
    }

    public Integer getCode() {
        return code;
    }

    public ExCode getEx() {
        return ex;
    }

    public String getName() {
        return name;
    }
}
